import { defineStore } from 'pinia'

export const useHouseStore = defineStore('house', {
  state: () => ({
    houseId: 85
  }),
  actions: {
    setHouseId(id) {
      this.houseId = id
      // 可选：持久化保存
      uni.setStorageSync('houseId', id)
    }
  }
})
let houseId = 85

export function getHouseId() {
  if (!houseId) {
    houseId = uni.getStorageSync('houseId') || null
  }
  return houseId
}

export function setHouseId(id) {
  houseId = id
  uni.setStorageSync('houseId', id)
}
